<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\massage\model;

class OrderData extends \app\BaseModel
{
    protected $name = "massage_service_order_list_data";
    public function dataAdd($data)
    {
        $res = $this->insert($data);
        return $res;
    }
    public function dataUpdate($dis, $data)
    {
        $res = $this->where($dis)->update($data);
        return $res;
    }
    public function dataList($dis, $page)
    {
        $data = $this->where($dis)->order("id desc")->paginate($page)->toArray();
        return $data;
    }
    public function dataInfo($dis)
    {
        $data = $this->where($dis)->find();
        if(empty($data)) {
            $this->dataAdd($dis);
            $data = $this->where($dis)->find();
        }
        return !empty($data) ? $data->toArray() : [];
    }
    public function orderDataAdd($order_id, $uniacid, $pay_model, $input = [])
    {
        $config = getConfigSettingArr($uniacid, ["coupon_bear_coach", "coupon_bear_admin", "add_flow_path", "wx_point", "ali_point", "balance_point", "poster_point", "poster_coach_share", "poster_admin_share", "comm_coach_balance"]);
        if($pay_model == 2) {
            $point = $config["balance_point"];
        } elseif($pay_model == 3) {
            $point = $config["ali_point"];
        } elseif($pay_model == 4) {
            $point = $config["balance_point"];
        } else {
            $point = $config["wx_point"];
        }
        $order_model = new Order();
        $coach_model = new Coach();
        $city_model = new City();
        $order = $order_model->dataInfo(["id" => $order_id]);
        if($order["is_add"] == 1) {
            $config["add_flow_path"] = $this->where(["order_id" => $order["add_pid"]])->value("add_flow_path");
        }
        $city_id = $coach_model->where(["id" => $order["coach_id"]])->value("city_id");
        $skill_balance = $city_model->where(["id" => $city_id])->value("skill_service_balance");
        $insert = ["order_id" => $order_id, "uniacid" => $uniacid, "pay_point" => $point, "poster_point" => $config["poster_point"], "poster_coach_share" => $config["poster_coach_share"], "poster_admin_share" => $config["poster_admin_share"], "skill_balance" => $skill_balance, "add_flow_path" => $config["add_flow_path"], "coupon_bear_coach" => $config["coupon_bear_coach"], "coupon_bear_admin" => $config["coupon_bear_admin"], "member_discount_cash" => $input["member_discount_cash"], "member_discount_balance" => $input["member_discount_balance"], "balance_discount_cash" => $input["balance_discount_cash"], "late_notice" => 0, "receiving_order_notice" => 0];
        if(isset($order["pay_model"]) && $order["pay_model"] == 2) {
            $insert["comm_coach_balance"] = $config["comm_coach_balance"];
        }
        $res = $this->dataAdd($insert);
        return $res;
    }
}

?>